// pages/caculate/caculate.js
Page({
  data:{
    perhourseSalary:0,
    totalHourse:0,
    kaohe:0,
    jiang:0,
    buzhu:0,
    kaoqin:0,
    fee:0,
    livingfee:0,
    otherfee:0,
    salary:0,
    hiddenModal:true,
    msg:""
  },
   listenerConfirm:function(){
      this.setData({
           hiddenModal:!this.data.hiddenModal
         })
  },
  listenerCancel:function(){
      this.setData({
           hiddenModal:!this.data.hiddenModal
         })
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  },
  caculate:function(){
   
      var perhourseSalary=   this.data.perhourseSalary|0;
      var totalHourse=  this.data.totalHourse|0;
      var kaohe= this.data.kaohe|0;
      var jiang= this.data.jiang|0;
      var buzhu= this.data.buzhu|0;
      var kaoqin= this.data.kaoqin|0;
      var fee= this.data.fee|0;
      var livingfee=  this.data.livingfee|0;
      var otherfee= this.data.otherfee|0;
      var salary= this.data.salary|0;
      if(perhourseSalary==0){
        this.setData({
              msg:'请输入正确的工价',
              hiddenModal:!this.data.hiddenModal,
        });         
        return false;
      }
      if(totalHourse==0){
        this.setData({
              msg:'请输入正确的出勤工时',
              hiddenModal:!this.data.hiddenModal,
        });         
        return false;
      }
        
      salary=   perhourseSalary*totalHourse+jiang+buzhu-kaohe-kaoqin-fee-livingfee-otherfee;
  
  this.setData({
       salary:salary,
  })
 
  
  },
  perhourseSalary:function(e){
  this.data.perhourseSalary=e.detail.value;
  },
  totalHourse:function(e){
  this.data.totalHourse=e.detail.value;
  },
  kaohe:function(e){
    this.data.kaohe=e.detail.value;
  },
  jiangli:function(e){
   this.data.jiang=e.detail.value;
   
  },
  kaoqin:function(e){
    this.data.kaoqin=e.detail.value;
  },
  buzhu:function(e){
this.data.buzhu=e.detail.value;
  },
  fee:function(e){
this.data.fee=e.detail.value;
  },
   livingfee:function(e){
this.data.livingfee=e.detail.value;
   },
   otherfee:function(e){
this.data.otherfee=e.detail.value;
   },
onShareAppMessage: function () {
    return {
      title: '工资帮计',
      desc: '工资计算帮手',
      path: '/pages/caculate/caculate'
    }
  }
})